<template>
    <div id="zhenshi">
        <table>
            <tr>
                <td>书籍</td>
                <td>阅读量</td>
                <td>评论量</td>
                <td>发行时间</td>
                <td>操作</td>
            </tr>
            <tr v-for="i in bookslist" :key="i.id">
                <td>{{i.name}}</td>
                <td>{{i.read | bian_ren}}</td>
                <td>{{i.commit}}</td>
                <td>{{i.time}}</td>
                <td @click="delet(i)">删除</td>
            </tr>
        </table>
    </div>
</template>
<script>
import {zhan_books,delet_books}  from './axios_api/api.js'
export default {
    name:"zhenshi",
    data(){
        return{
            bookslist:[],
        }
    },methods:{
        zhan(){
            zhan_books()
            .then(res=>{
                console.log(res)
                this.bookslist = res.data
            })
        },
        delet(i){
             var data={"id":i.id}
                delet_books(data)
                .then(res=>{
                    console.log(res)
                    if(res.code==200){
                        alert("删除成功")
                    }else{
                        alert("删除失败")
                    }
                })
        }
    },created(){
        this.zhan()
    },
    filters:{ 
        bian_ren(val){
            var num = parseInt(val)
            var aaa = num/100
            var ccc_str = String(aaa) 
            return ccc_str + "人"
        }
        
    }
}
</script>
<style>
    
</style>